package com.example.feilin.controller;

import java.util.HashMap;
import java.util.Map;

import com.example.feilin.entity.Vehicle;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

public class VehicleController extends Controller{

	public void index() {
		render("list.html");
	}
	
	public void json() {
		Page<Vehicle> page = Vehicle.me.paginate(getParaToInt("page"), getParaToInt("pagesize"));
		renderJson(page);
	}
	
	public void form() {
		render("form.html");
	}
	
	public void save() {
		Vehicle v = getModel(Vehicle.class);
		
		boolean result = v.save();
		Map map = new HashMap();
		if (result) {
			map.put("code", 200);
		} else {
			map.put("code", 300);
		}
		renderJson(map);
	}
}
